

/**
 * Created with IntelliJ IDEA.
 * User: 12629
 * Date: 2021/10/19
 * Time: 8:38
 * Description:
 */

class Person {
    //1、字段-》属性-》定义在方法的外部，类的内部  -》成员变量
    public String name;
    public int age;
    //public int[] array = new int[10];
    public static int count = 10;

    //2、方法 -> 行为->成员方法
    public void eat() {
        //int a = 10;
        System.out.println(name+"吃饭！");
    }

    public void sleep() {
        func();
        //static int a = 99;
        System.out.println(name+"睡觉！");
    }

    public static void func() {
        count = 999;
        //eat();
        //int a = 10;//局部变量
        //System.out.println(name+"静态方法执行了！");
    }
}

class Test {
    public int a;
    public static int count;
}

class Cat {
    private String name;
    private int age;
    private String sex;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public void eat() {
        System.out.println(name+"在吃！");
    }
    public void sleep() {
        System.out.println(name+"在睡！");
    }
    public void jump() {
        System.out.println(name+"在跳！");
    }
    public void show() {
        System.out.println("姓名："+name+" 年龄："+age+" 性别："+sex);
    }
    //自己实现一个toString 方法

    @Override//注解
    public String toString() {
        return "Cat{" +
                "姓名='" + name + '\'' +
                ", 年龄=" + age +
                ", 性别='" + sex + '\'' +
                '}';
        //return "bit";
    }
}

public class TestDemo {

    public static void main(String[] args) {
        Cat cat1 = new Cat();
        //cat1.name = "咪咪";
        cat1.setName("咪咪");

        System.out.println(cat1.getName());
        //cat1.sex = "女";
        cat1.setSex("女");
        //cat1.age = 1;
        cat1.setAge(1);

        System.out.println(cat1);//ctrl+鼠标左键
    }

    /*public static void main16(String[] args) {
        Cat cat1 = new Cat();
        cat1.name = "咪咪";
        cat1.sex = "女";
        cat1.age = 1;
        cat1.eat();
        cat1.sleep();
        cat1.jump();
        cat1.show();
        System.out.println("==============");
        Cat cat2 = new Cat();
        cat2.name = "咪咪2";
        cat2.sex = "女2";
        cat2.age = 12;
        cat2.eat();
        cat2.sleep();
        cat2.jump();
        cat2.show();
    }*/




    public void func2() {
        System.out.println("fdsafasdaa");
    }


    public static void main14(String[] args) {
        /*Person person = new Person();
        person.sleep();*/
        //Person.func();
        //func2();
        TestDemo testDemo = new TestDemo();
        testDemo.func2();
    }

    public static void main12(String[] args) {
        Test t1 = new Test();
        t1.a++;
        Test.count++;
        System.out.println(t1.a);
        System.out.println(Test.count);
        System.out.println("============");
        Test t2 = new Test();
        t2.a++;
        Test.count++;
        System.out.println(t2.a);
        System.out.println(Test.count);
    }

    public static void main11(String[] args) {
        System.out.println(Person.count);
        Person person = null;
        System.out.println(person.count);
        System.out.println(((Person)null).count);
        System.out.println("============");
        Person.func();
    }

    public static void main10(String[] args) {
        Person person = new Person();
        person.name = "bit";
        System.out.println(person.name);

        System.out.println("============");
        //System.out.println(person.count);
    }

    public static void main9(String[] args) {
        Person person = new Person();
        person = new Person();
        person = new Person();
        person = new Person();
        person = new Person();
        person = new Person();

        int[] array = new int[10];
        array = new int[4];
        array = new int[41];
        array = new int[14];
        array = new int[24];
    }

    public static void main8(String[] args) {
        Person person = new Person();
        Person person2 = person;
    }

    public static void main7(String[] args) {
        Person person = null;//不指向任何对象
        person.name = "haha";
        System.out.println(person.name);
    }

    public static void main6(String[] args) {
        //int a = 10;
        Person person = new Person();
        //引用.属性
        person.name = "bit";
        person.age = 18;
        System.out.println(person.name);
        System.out.println(person.age);
        //引用.方法
        person.eat();
        person.sleep();
        System.out.println("==============");
        Person person2 = new Person();
        person2.name = "bit2";
        person2.age = 182;
        System.out.println(person2.name);
        System.out.println(person2.age);
        person2.eat();
        person2.sleep();
        /*Person person3 = new Person();
        Person person4 = new Person();*/


        //System.out.println(person);
    }

    public static void main5(String[] args) {
        int[][] array = {{1,2},{4,5,6}};
        int[][] array2 = {{1,2,3,4,5},{4,5},{9,8}};
        int[][] array3 = new int[2][3];//0
        int[][] array4 = new int[][]{{1,2,3},{4,5,6}};
    }

    public static void main3(String[] args) {
        //不规则的二维数组
        int[][] array = new int[2][];
        array[0] = new int[3];
        array[1] = new int[5];


        /*System.out.println(array[0]);
        System.out.println(array[1]);
*/

        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array[i].length; j++) {
                System.out.print(array[i][j]+" ");
            }
            System.out.println();
        }
    }

    public static void main2(String[] args) {
        int[][] array = {{1,2,3},{4,5,6}};
        System.out.println("行数："+array.length);
        System.out.println("列数："+array[0].length);

        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array[i].length; j++) {
                System.out.print(array[i][j]+" ");
            }
            System.out.println();
        }
    }


    public static void main1(String[] args) {
        int[][] array = {{1,2,3},{4,5,6}};
        int[][] array2 = {{1,2},{4,5},{9,8}};
        int[][] array3 = new int[2][3];//0
        int[][] array4 = new int[][]{{1,2,3},{4,5,6}};

    }
}
